package com.tan.pojo;

import java.time.LocalDate;
import java.util.Objects;

public class Employee {
    private String name;
    private double salary;
    private LocalDate hireDay;

    public Employee(String name, double salary,int year, int month,int day) {
        this.name = name;
        this.salary = salary;
        this.hireDay = LocalDate.of(year,month,day);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public LocalDate getHireDay() {
        return hireDay;
    }

    public void setHireDay(LocalDate hireDay) {
        this.hireDay = hireDay;
    }

    //
    public void raiseSalary(double byPercent){
        double raise = salary*byPercent/100;
        salary+=raise;
    }

    public boolean equals(Object otherObject){
        //a quick test to see if the objects are identical.
        //快速测试以查看对象是否相同。
        if (this == otherObject)return true;

        //must return false if the explicit parameter is null
        //如果显示参数为null，必须返回false
        if (otherObject == null)return false;

        //if the classes don't match,they can't be equal
        //如果这个类别不匹配，他们不可能相等
        if (getClass() != otherObject.getClass())return false;

        //
        Employee other =(Employee) otherObject;

        return Objects.equals(name,other.name) && salary == other.salary && Objects.equals(hireDay,other.hireDay);
    }
    public int hashCode(){
        return Objects.hash(name,salary,hireDay);
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", salary=" + salary +
                ", hireDay=" + hireDay +
                '}';
    }
}
